<%@page import="com.rw.table.Itempicture"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.List"%>
<%@page import="com.rw.table.Item"%>
<%@page import="java.text.DecimalFormat"%>
<%@ page language="java" contentType="text/html; charset=gbk"
    pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  ??http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd??>

<html>
  <head>
    <base href="<%=basePath%>">
    <%@taglib prefix="s" uri="/struts-tags"%>
    <meta http-equiv="Content-Type" content="text/html; charset=gbk">
    <title>商品搜索结果页面-B2C-racewind商城</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	
	
	<style  type="text/css">
			@import "./css/back/header_back.css";
			@import "./css/back/item_manage.css";
	</style>
	
	<script language="javascript" type="text/javascript" src="javascript/Admin/item_manage.js">
	</script> 
	<script language="javascript" type="text/javascript" src="javascript/commonCheck.js">
	</script> 
	

  </head>
  
  <body>
  <jsp:include flush="true" page="header_back.jsp"></jsp:include>      
     <div class="backItemFrame">		
		<div class="itemList">
			<h2><strong>商品搜索结果列表</strong></h2>
	<%
    	Integer nowPage = (Integer)request.getAttribute("nowPage");
    	Integer totalPageNum = (Integer)request.getAttribute("totalPageNum");
    	DecimalFormat df = new DecimalFormat("#0.00");
    	String itemName = (String)request.getAttribute("itemName");
        Float itemMarketPriceUp = (Float)request.getAttribute("itemMarketPriceUp");
    	Float itemMarketPriceLow = (Float)request.getAttribute("itemMarketPriceLow");
    	Float itemdiscountUp = (Float)request.getAttribute("itemdiscountUp");
    	Float itemdiscountLow = (Float)request.getAttribute("itemdiscountLow");
    	Long itemIndexId = (Long)request.getAttribute("itemIndexId");
    	
    	if(nowPage == null || totalPageNum == null){
    %>
    	<table border="0" align="center">
     		<tr>
     			<td>
     			<a>    </a> 
     			</td>
     		</tr>
     		<tr>
     			<td>
     			<a>没有可显示的数据</a> 
     			</td>
     		</tr>
     	</table>
    <%
    	}else{
    %>
			<div class="itemListTable">
			<form id="itemListShow" method="post">
				<table> 	
					<tr>
						<%
						@SuppressWarnings("unchecked")
						List<Item> itemList = (List<Item>)request.getAttribute("items");
						@SuppressWarnings("unchecked")
						List<Itempicture> itempictures = (List<Itempicture>)request.getAttribute("itempictures");
						if(itemList!= null && itempictures != null){
							Iterator<Item> iterator = itemList.iterator();
							Iterator<Itempicture> iterator2 = itempictures.iterator();
							while(iterator.hasNext() && iterator2.hasNext()){
								Item item = iterator.next();
								Itempicture itempicture = iterator2.next();
						%>
						<td>
						<div class="itemDetail">
							<%
								if(itempicture.getItemPicId() < 0){
							%>
							<a href=<%="displayItemInfoAction?itemId=" + item.getItemId() %>><img src="images/item/PPT.jpg"/></a>
							<%
								}else{
									String picSrc = "uploadPicture/" + itempicture.getItemPicSrc();
							%>
							<a href=<%="displayItemInfoAction?itemId=" + item.getItemId() %>><img  width="100" height="100" src="<%=picSrc %>"/></a>
							<%
								} 
							%>
							<p><%=item.getItemName() %></p>
							<p>市场价:<%=df.format(item.getItemMarketPrice())%></p>
							<p>折扣价:<%=df.format(item.getItemMarketPrice() * item.getItemdiscount())%></p>
							<p>
							<a href=<%="getModifyItemAction?nowPage=" + nowPage +"&itemId=" + item.getItemId()%>>修改</a>
							<%if(item.getItemDrop() == 0){ %>
							<a href=<%="changeItemStateAction?nowPage=" + nowPage +"&itemId=" + item.getItemId() + "&state=1"%>>下架</a>
							<%}else{ %>
							<a href=<%="changeItemStateAction?nowPage=" + nowPage +"&itemId=" + item.getItemId() + "&state=0"%>>上架</a>
							<%} %>
							</p>
							</div>							
						</td>
							<%} %>
						<%} %>
					</tr>					
				</table>
			</form>
			</div>
			<div class="pagechose">
				<%if(totalPageNum == 0){ %>
				<a>当前目录没有商品</a>
				<%}else{ %>
					<% 
						String basetemp = "adminSearchItemAction?";
						basetemp += "&itemMarketPriceUp=" + itemMarketPriceUp;
						basetemp += "&itemMarketPriceLow=" + itemMarketPriceLow;
						basetemp += "&itemdiscountUp=" + itemdiscountUp;
						basetemp += "&itemdiscountLow=" + itemdiscountLow;
						basetemp += "&itemIndexId=" + itemIndexId;
						basetemp += "&itemName=" + itemName;
					%>
					<%if(nowPage - 1 != 0){ %>
						<a href=<%=basetemp + "&nowPage=" + (nowPage - 1)%> >上一页</a> 
					<%} %>
					<%for(int i = 0; i < 4; i ++){ %>
						<%if(nowPage - 4 + i > 0){ %>
							<a href=<%=basetemp + "&nowPage=" + (nowPage - 4 + i)%> ><%=(nowPage - 4 + i) %></a> 
						<%} %>
					<%} %>
					<a style="text-decoration: underline;"><%=nowPage %></a> 
					<%for(int i = 0; i < 3; i ++){ %>
						<%if(nowPage + i + 1 <= totalPageNum){ %>
							<a href=<%=basetemp + "&nowPage=" + (nowPage + i + 1)%> ><%=(nowPage + i + 1) %></a> 
						<%} %>
					<%} %>
					<%if(nowPage + 1 <= totalPageNum){ %>
					<a href=<%=basetemp + "&nowPage=" + (nowPage + 1)%> >下一页</a>
					<%} %>
				<%} %>
			</div>
			<hr>
		</div>
		</div>
     <%
    	}
     %>
     <jsp:include page="../B2C/footer.jsp" flush="true"></jsp:include>
  </body>
</html>
